/*
 * Copyright (C) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef IMAGE_KNIFE_C_KEKE_IMAGEKNIFE_LOADER_INTERNAL_H
#define IMAGE_KNIFE_C_KEKE_IMAGEKNIFE_LOADER_INTERNAL_H

#include "imageknife_loader.h"
#include "imageknife_task_internal.h"

namespace ImageKnifePro {

class ImageKnifeLoaderInternal : public ImageKnifeLoader {
public:
    bool LoadFromMemory(std::shared_ptr<ImageKnifeTaskInternal> task);

    bool LoadFromFile(std::shared_ptr<ImageKnifeTaskInternal> task);

    bool WriteCacheToMemory(std::shared_ptr<ImageKnifeTaskInternal> task);

    bool WriteCacheToFile(std::shared_ptr<ImageKnifeTaskInternal> task);

    bool DownloadImage(std::shared_ptr<ImageKnifeTaskInternal> task);

    bool DecodeImage(std::shared_ptr<ImageKnifeTaskInternal> task);

    void AddMemoryCacheInterceptor(std::shared_ptr<MemoryCacheInterceptor> interceptor,
                                   Position position = Position::START) override;

    void AddFileCacheInterceptor(std::shared_ptr<FileCacheInterceptor> interceptor,
                                 Position position = Position::START) override;

    void AddLoadInterceptor(std::shared_ptr<LoadInterceptor> interceptor,
                                Position position = Position::START) override;

    void AddDecodeInterceptor(std::shared_ptr<DecodeInterceptor> interceptor,
                              Position position = Position::START) override;

private:
    std::shared_ptr<MemoryCacheInterceptor> memoryInterceptorHead_ = nullptr;
    std::shared_ptr<MemoryCacheInterceptor> memoryInterceptorTail_ = nullptr;

    std::shared_ptr<FileCacheInterceptor> fileInterceptorHead_ = nullptr;
    std::shared_ptr<FileCacheInterceptor> fileInterceptorTail_ = nullptr;

    std::shared_ptr<LoadInterceptor> loadInterceptorHead_ = nullptr;
    std::shared_ptr<LoadInterceptor> loadInterceptorTail_ = nullptr;

    std::shared_ptr<DecodeInterceptor> decodeInterceptorHead_ = nullptr;
    std::shared_ptr<DecodeInterceptor> decodeInterceptorTail_ = nullptr;
};

} // end of namespace

#endif // IMAGE_KNIFE_C_KEKE_IMAGEKNIFE_LOADER_INTERNAL_H
